package com.scenic.rd_android.memory;

import android.content.Intent;
import android.os.Handler;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;

import com.nova.scenic.projectlibs.util.debug.MyLog;
import com.scenic.rd_android.MyActivityTestRule;
import com.scenic.rd_android.TestUtils;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * Created by scenic on 16/6/4.
 */
@RunWith(AndroidJUnit4.class)
@LargeTest
public class TestMemoryLack1Activity {

    private static final java.lang.String TAG = "TestMemoryLack1Activity";

    public MyActivityTestRule<MemoryLack1Activity> memoryActivityActivityTestRule =
            new MyActivityTestRule<>(MemoryLack1Activity.class, true, true);

    @Before
    public void memoryTestBefore(){
        MyLog.i(TAG,"memory test before");
    }

    @After
    public void memoryTestAfter(){
        MyLog.i(TAG,"memory test before");
    }

    @Test
    public void launcherActivityManyTimes() {

        memoryActivityActivityTestRule.launchActivity(new Intent());

        memoryActivityActivityTestRule.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {

                    }
                },100);
            }
        });
    }


    @Test
    public void rotateOrientation(){
        launcherActivityManyTimes();

//        synchronized (this){
//            try {
//                wait(10000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }

        for(int i = 0; i < 100;i++){
            TestUtils.rotateOrientation(memoryActivityActivityTestRule);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }

    }



}
